<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <title>美业红</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1">
        <link href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
        <link href="/public/css/main.css" rel="stylesheet">
        <script type='text/javascript' src='/public/js/jquery-3.1.1.min.js'></script>
        <script type="text/javascript" src='/public/js/jquery.validate.js'></script>
        <script type="text/javascript" src='/public/js/main/main.js'></script>
        <script>
            var _hmt = _hmt || [];
            (function () {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?8d43b5b5d798921b66d689f7a792e6e2";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        </script>
        <script type="text/javascript">
            document.domain = '<?php echo _DOMAIN_ALL_;?>';
        </script>
        <link rel="shortcut icon" type="image/ico" href="/favicon.ico">
    </head>
    <body style="background-color: #f4f4f4;">
        <div class="navigation">
            <div class='navlogo'>
            <a href='/'><img class='_navlogo' src="/public/images/logo.png"></a>
            </div>
            <div class='navson'>
                <ul class='fr'>
                <li><a href='/' class='anchor'><b>主页</b></a></li>
                <li><a href="/home/store" class='anchor'><b>店铺</b></a></li>
                <li><a href="/home/barber" class='anchor'><b>成员</b></a></li>
                <li><a href="/home/action" class='anchor'><b>活动</b></a></li>
                <li><a href="/home/order" class='anchor'><b>订单</b></a></li>
                <li><a href="/home/coupon" class='anchor'><b>优惠券</b></a></li>
                <li><a href="/home/goods" class='anchor'><b>商品</b></a></li>
                </ul>
           </div>
            <?php if($_SESSION['id']>0){?>
            <div style="float:right;padding-right:10%">你好:<span id='login_name'></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='anchor' href='/home/passport/repassword'>修改密码</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='anchor' href='/home/passport/logout'>退出</a></div>
            <?php }?>
        </div>
        <div style='margin-top:80px;width:100%'>
            <img class='_navlogo' src="/public/images/contentlogo.png" style='width:100%;height:100px'>
        </div>
        <div class='container'>
            <div class='_main'>
            <div class='_line'></div> 
<?php if($order_info[0]['id']<1 ){?>
<div style="text-align: center">
    <div style="height: 5rem"></div>
    <h3>老版本的订单没有订单详情。</h3>
    <div>
        <a href='#' onclick='javascript:history.back(-1);'>返回上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
        <a href='/' >返回首页</a>
    </div>
</div>
<?php }else{ ?>
<div style='text-align: right'>
    <?php if($order['status']==1) { ?>
    <a href="/home/order/update?id=<?php echo $order_info[0]['order_id'];?>" onclick="return over();">订单子项消费全部完毕，关闭（完成）订单。</a>
    <?php }else{ ?>
    <a href='/home/order' >返回上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <?php } ?>
</div>

<div class="_cut"></div>
<div id='content' style='padding:5rem'>
    <?php foreach($order_info as $k=>$v){ ?>
    <div class="form-group row">
        商品名：<a target='_blank' href='/home/goods/detail?id=<?php echo $v['item_id'];?>&store_id=<?php echo $v['store_id'];?>'><b><?php if($v['item']['items']){ echo $v['item']['items'][$k]['name']; }else{ echo $v['item']['name'];}?></b></a>&nbsp;&nbsp;&nbsp;&nbsp;
        剩余：<b id='num_<?php echo $v['id'];?>' class='number'><?php echo $v['count'];?></b>&nbsp;次/个&nbsp;&nbsp;&nbsp;&nbsp;
        <?php if($v['count']>0 && $order['status']!=0){?>
        <input type='button' value='消费一次' onclick='sub(<?php echo $v['order_id'];?>,<?php echo $v['id'];?>);'>&nbsp;&nbsp;&nbsp;&nbsp;
        <?php }?>
        <?php if($order['status']==1){?>
        <input type='button' value='撤销一次' onclick='sub(<?php echo $v['order_id'];?>,<?php echo $v['id'];?>,1);'> 
        <?php }?>
    </div>
    <?php }?>
</div>
<script type='text/javascript'>
    function sub(order_id,id,bool){
        var url = "/home/order/";
        var number = $("#num_"+id).html();
        number = parseInt(number);
        if(bool != 1){
            url += "subtract?order_info_id="+id+'&order_id='+order_id;
            number = number-1;
        }else{
            url += "add?order_info_id="+id+'&order_id='+order_id;
            number = number+1;
        }
        $.ajax({
            url: url,
            async: true,
            success: function (data) {
                if (data == 'false') {
                    alert('操作失败，请稍候再试。');
                    return;
                }
                alert('操作成功');
                $("#num_"+id).html(number);
            }
        });
    }
    function over(){
        if(confirm('确定要执行此操作吗?')){
            var bool = true;
            $(".number").each(function(i){
                var num = $(this).html();
                num = parseInt(num);
                if(num>0){
                    bool = false;
                }
            });
            if(bool == false){
                alert("还有未完成的订单子项！！");
            }
            return bool;
        }
        return false;
    }
</script>
<?php }?>

</div>
</div>
<div class='_line'></div>
<div class="newfooter">
    ©2015-2017 All Rights Reserved ( 京ICP备15010043号 ) 
</div>
<div id='mask_layer' style="text-align: center;width:100%;height:100%;overflow:hidden;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8E8E8E',endColorstr='##8E8E8E');
     background-color:rgba(255, 255, 255, 0.4);position:fixed; _position:absolute; top:0;left:0; z-index:5000;display:none ">
    <div style="padding-top: 20%"><h1><b>loading<span id="_loading"></span></b></h1></div>
</div>
</body>
<script type="text/javascript" src='/public/js/top.js'></script>
</html>